package db_main

import (
	"errors"
	"fmt"
	"gorm.io/gorm"
	"longmen/server/config/global"
	utils2 "longmen/server/pkg/common/helper/util"
	"longmen/server/pkg/db/mysql/models/models_main"
)

func GetAutoPushById() (*models_main.AutoPush, error) {
	o := &models_main.AutoPush{}
	err := global.GetR().Model(&models_main.AutoPush{}).
		Where("id=?", 1).
		Take(&o).
		Error
	if errors.Is(err, gorm.ErrRecordNotFound) {
		err = nil
	}
	if err != nil {
		err = fmt.Errorf("%s%s", utils2.Convert2(), err.Error())
	}
	return o, nil
}
